package com.java.utils;

import java.util.Arrays;

public class AssertUtil {
    public static void notNull(Object... params) {
        notNull("object can not be null", params);
    }

    public static void notNull(String msg, Object... params) {
        Arrays.stream(params).forEach(item -> {
            if (item instanceof String) {
                if (EmptyUtils.isEmpty((String) item) || EmptyUtils.isTrimBlank((String) item)) {
                    throw new RuntimeException(msg);
                }
            } else {
                if (item == null) {
                    throw new RuntimeException(msg);
                }
            }
        });
    }

    public static void isTrue(Object... params) {
        Arrays.stream(params).forEach(item -> {
            if ((Boolean) item == false) {
                throw new RuntimeException("object should be true");
            }
        });
    }


    /**
     * 大于0正整数
     */
    public static void positiveInteger(Integer... params) {
        Arrays.stream(params).forEach(item -> {
            if (item == null || item <= 0) {
                throw new RuntimeException("Integer value should bigger than ZERO");
            }
        });
    }

}
